package controller;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class Test {
    public static void main(String[] args) {
        try {
            // 组员写代码
            // 组员写了代码
            // 组长写的
            // 再写代码
            Connection connection = JdbcUtils.getConnection();
            String sql = "select * from user";
            PreparedStatement preparedStatement = connection.prepareStatement(sql);
            ResultSet resultSet = preparedStatement.executeQuery();
            User user = null;
            while (resultSet.next()) {
                int id = resultSet.getInt("id");
                String name = resultSet.getString("username");
                String password = resultSet.getString("password");
                user = new User(id, name, password);
            }
            System.out.println(user);
            JdbcUtils.close(resultSet, preparedStatement, connection);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
